import java.util.Scanner;

/**
 * @author gao
 * @date 2025/10/9 8:11
 */

class ListNode {
    int val;
    ListNode next;

    public ListNode() {
    }

    public ListNode(int val) {
        this.val = val;
    }

    public ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }
}

public class Solution {
    public ListNode sortList(ListNode head) {
        if (head == null || head.next == null) {
            return head;
        }

        // 查找链表的中间节点
        ListNode fast = head.next, slow = head;
        while (fast != null && fast.next != null) {
            fast = fast.next.next;
            slow = slow.next;
        }

        // 分割链表
        ListNode mid = slow.next;
        slow.next = null;


        // 递归排序两个子链表
        ListNode left = sortList(head);
        ListNode right = sortList(mid);

        // 合并两个有序链表
        return merge(left, right);
    }

    private ListNode merge(ListNode l1, ListNode l2) {
        ListNode newH = new ListNode(-1);
        ListNode tmp = newH;

        while (l1 != null && l2 != null) {
            if (l1.val < l2.val) {
                tmp.next = l1;
                l1 = l1.next;
            } else {
                tmp.next = l2;
                l2 = l2.next;
            }
            tmp = tmp.next;
        }

        if (l1 != null) {
            tmp.next = l1;
        } else {
            tmp.next = l2;
        }
        return newH.next;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            ListNode head = null;
            ListNode tail = null;

            for (int i = 0; i < n; i++) {
                int val = in.nextInt();
                ListNode newH = new ListNode(val);
                if (head == null) {
                    head = newH;
                    tail = newH;
                } else {
                    tail.next = newH;
                    tail = newH;
                }
            }
            Solution solution = new Solution();
            printList(solution.sortList(head));
        }
    }

    private static void printList(ListNode head) {
        ListNode cur = head;
        while (cur != null) {
            System.out.print(cur.val + " ");
            cur = cur.next;
        }
        System.out.println();
    }
}